package com.slz3.business.module.systemManagement.sysUser.domain;

import com.slz3.business.frame.enums.AuditFlag;
import com.slz3.business.frame.enums.UsingFlag;
import com.slz3.business.frame.util.UUIDUtils;
import com.slz3.business.frame.util.VE;

import java.time.LocalDateTime;

public class SysUserFactory {

    /**
     * 初始化基础属性值
     */
    public static SysUser initBaseFields(SysUser sysUser) {
        if (sysUser.getUuid() == null) {
            sysUser.setUuid(UUIDUtils.generateUUID());
            sysUser.setCreateTime(LocalDateTime.now());
            sysUser.setSerAudit(AuditFlag.APPROVED);
            if (VE.isEmpty(sysUser.getSerUsing())) {
                sysUser.setSerUsing(UsingFlag.ENABLE);
            }
        } else {
            sysUser.setLastModifyTime(LocalDateTime.now());
        }
        return sysUser;
    }

    /**
     * 初始化基础属性值
     */
    public static SysUser initBaseFields() {
        return initBaseFields(newTemStyle());
    }

    public static SysUser newTemStyle() {
        return new SysUser();
    }

}
